package za.org.jcicada.genss.alarm.impl;

/**
 * AlarmAcceptListener.java
 *
 * @author Simon Cross
 *
 * Created on February 9, 2009, 16:08
 */

import za.org.jcicada.comms.IConnection;
import za.org.jcicada.comms.IKatcpSerializerStrategy;
import za.org.jcicada.comms.IMessageListener;
import za.org.jcicada.comms.impl.AcceptListenerBase;
import za.org.jcicada.genss.alarm.IAlarmSubject;
import za.org.jcicada.genss.alarm.katcp.AlarmKatcpSerializer;

/**
 * Katcomms accept listener that accepts connections and ties them to
 * a given IAlarmSubject.
 */
public class AlarmAcceptListener extends AcceptListenerBase {

    /**
     * IAlarmSubject implementation to delegate requests to.
     */
    protected IAlarmSubject alarmSubject;

    /**
     * Create an accept listener that listens for clients and passes
     * messages through to the given IAlarmSubject implementation.
     */
    public AlarmAcceptListener(IAlarmSubject alarmSubject) {
        this.alarmSubject = alarmSubject;

    }

    /**
     * Create message listeners for new connections.
     * Implements abstract method from AcceptListenerBase.
     *
     * @param connection  New connection from client.
     */
    public IMessageListener createListener(IConnection connection) {
        return new AlarmMessaging(connection, alarmSubject);
    }

	@Override
	public IKatcpSerializerStrategy getKatcpSerializerStrategy() {
		return new AlarmKatcpSerializer();
	}

}
